<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>美兰数据文化馆与图书馆</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/css/public.css" media="all">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/huazhi/images/favicon.ico"/>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-form">
                <blockquote class="layui-elem-quote">
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <select name="type" lay-filter="LAY-user-adminrole-type" id="type">
                                <option value="">请选择</option>
                                <option value="全部">全部盘点</option>
                            </select>
                        </div>
                        <button class="layui-btn" id="search_btn" data-type="reload">合并盘点单号</button>
                    </div>
                </blockquote>
            </div>
            <table class="layui-hide" id="inventoryList" lay-filter="inventoryLists"></table>
            <div id="laypage"></div>
        </div>
    </div>
</div>
<input type="hidden" id="curnum" value="1">
<script type="text/html" id="states">
    {{#  if(d.state== '未盘到'){}}
    <button class="layui-btn layui-btn-primary layui-btn-xs">未盘到</button>
    {{#  } else {}}
    <button class="layui-btn layui-btn-xs">盘到</button>
    {{#  } }}
</script>
<script src="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/layui.all.js"></script>
<script src="<%=request.getContextPath()%>/huazhi/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['laydate', 'form', 'table', 'inventory'], function () {
        var $ = layui.$
            , table = layui.table,
            form = layui.form;

        $.ajax({
            type: "post",
            url: "<%=request.getContextPath()%>/rest/system/getPlace",
            dataType: "json",
            async: false,
            success: function (data) {
                var arry = data.data
                var select = document.getElementById("type");
                for (var i = 0; i < arry.length; i++) {
                    select.options.add(new Option(arry[i], arry[i]));
                }
                form.render('select');
            }
        })

        //搜索事件
        var active = {
            reload: function () {  //data-type='reload'
                var searchval = $('#type').val();
                $('#curnum').val("1");
//                alert(searchval)
                table.reload('inventoryList', { //表格的id
                    where: {
                        key: searchval,
                        page: 1,
                        limit: 10,
                    },
                    text: {
                        none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
                    }
                })
            }
        };
        $('#search_btn').on('click', function () { //搜索的id
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });
</script>
</body>
</html>